
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>jQuery UI Dialog - Modal message</title>
	<link rel="stylesheet" href="css/jquery/theme/jquery-ui-1.9.1.custom.css"/>
 	<link rel="stylesheet" href="css/college.css"/> 
 <script src="js/jquery/jquery-1.8.2.js"></script>
 <script src="js/jquery/jquery-ui-1.9.1.custom.js"></script>
  <script src="js/jquery/jquery.validate.js"></script>

  <style>
		div.ui-datepicker{
			font-size:12px;
		}
		.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
		
	</style>
</head>

<body>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt"  prefix="c"%>
	
	


	<c:choose>
		<c:when test="${not empty errorMessage}">
			<c:set var="title" value="Error Occured"></c:set>
			<c:set var="message" value="${errorMessage}"></c:set>
		</c:when>
		<c:when test="${not empty successMessage}">
			<c:set var="title" value="Operation Succeded"></c:set>
			<c:set var="message" value="${successMessage}"></c:set>
		</c:when>
		<c:otherwise>
		</c:otherwise>
	</c:choose>
	
	<div id="message-dialog" title="${title}" style="display:none;">
		<p>${message}</p>
	</div>

<form:form id="form1" name="form1" method="post" action="saveattendance.htm" modelAttribute="attendanceFormModel" >

<div  id="options" align="right">
			<a href="selectclass.htm"  id="back"> Back </a> 
			<a href="iservicehome.htm" id="home">Home</a> 
			<a href="j_spring_security_logout" id="logout">Logout</a> 
</div>

<h2  style="margin-top:5px;" align="center"> &nbsp;Student  Attendance Form of  ${attendanceFormModel.branchCode} -  ${attendanceFormModel.year} - ${attendanceFormModel.sem}</h2>
	
 
<form:hidden path="branchCode"/>
<form:hidden path="year"/>
<form:hidden path="sem"/>
  <c:choose>
  	<c:when test="${studentList.size() == 0}">
  		
				<table border="0" align="center" cellpadding="5" id="branchform">
					<tr>
						<td align="center">Sorry!!</td>
					</tr>
					<tr>
						<td>No Students found for this class</td>

					</tr>

					
					<tr>
						<td colspan="2" align="center"><label> 
							<a href="selectclass.htm"> Select a Different Class</a>
						</label>
						</td>
					</tr>
				</table>
	</c:when>
	<c:otherwise>
		 <table  border="0" align="center" cellpadding="5" id="example" >
    <tr>
      <td valign="middle">Date:</td>
      <td><label>
        <form:input type="text" name="date" id="date"  path="date" readonly="true"/>
      </label></td>
      <td>Hour: </td>
      <td><form:select name="hour" id="hour" onChange="" path="hour">
        <option value="1">I</option>
        <option value="2">II</option>
        <option value="3">III</option>
        <option value="4">IV</option>
        <option value="5">V</option>
        <option value="6">VI</option>
        <option value="7">VII</option>
      </form:select></td>
      <td><label>Subject:</label></td>
      <td><form:input type="text" name="subject" id="subject" path="subject" /></td>
      <td>Faculty: </td>
      <td><label>
        <form:input type="text" name="faculty" id="faculty" path="faculty" />
      </label></td>
    </tr>
  </table>
  <p></p>
  <table  border="1" align="center" cellpadding="5" id="attendancetable">
    <tr>
      <th scope="col">S.No</th>
      <th scope="col">Hallticket Number</th>
      <th scope="col">Name</th>
      <th scope="col">Attendence</th>
    </tr>
    <c:forEach items="${studentList}" var="student" varStatus="i">
	  
	    <tr>
	    	<td align="center">
	    		${i.count}
	    	</td>
	      <td align="center">
		      <input type="hidden" name="attendanceList[${i.count}].id.student.htno" value="${student.htno}">
		      ${student.htno}
		  </td>
	      <td align="justify">${student.name} </td>
	      <td align="center">
	      	<div >
	            <form:radiobutton path="attendanceList[${i.count}].attendance" value="P" checked="checked"/> P &nbsp;&nbsp;
	            <form:radiobutton path="attendanceList[${i.count}].attendance" value="A"/> A
	            
			</div>
	       </td>
	    </tr>
    </c:forEach>
   
  </table>
  <p></p>
		<div align="center">
			
			<input type="submit" value="Save Attendance" id="save_attendance" />
		</div>
	</c:otherwise>
  
  </c:choose>
 


	</form:form>
 <script src="js/college.js"></script>
<script type="text/javascript">
	$(function() {
		
		$("#date").datepicker({ dateFormat: "dd-mm-yy","showAnim":"slide" });
		$("a").button();
		$("td").tooltip();
		//init();
		var title = "<c:out value='${title}'/>";
		if(title) {
			//alert();
			showDialog("message-dialog");
		
		}
			
		
		
	});
	

  	$(document).ready(function() { 
    // validate signup form on keyup and submit 
    $("#form1").validate({ 
        rules: { 
            
            date: "required", 
            subject: "required",
            faculty: "required" 
        }, 
        messages: { 
            date: "Date required", 
            subject: "Subject Required", 
            faculty: "Faculty Required" 
        
        }, 
        // the errorPlacement has to take the table layout into account 
        errorPlacement: function(error, element) { 
           // alert(element.name);
             error.insertBefore(element);
         
               element[0].title=error.text();
              /*  var text = error.text();
                new dialog(text).show();
    			element.tooltip({
      				content: function(){ return text; }
    			}).tooltip('open');*/
  
        }, 
        // specifying a submitHandler prevents the default submit, good for the demo 
       submitHandler: function(form) { 
            form.submit();
        }
        // set this class to error-labels to indicate valid fields 
     
    }); 
     
    // propose username by combining first- and lastname 
    
 
}); 

	
</script>

	

</body>
</html>
